using Microsoft.EntityFrameworkCore;
using ShardingCore.Core.DbContextCreator;
using ShardingCore.Sharding.Abstractions;
using sharecore;
using WalkingTec.Mvvm.Core;

namespace ShardingWTM
{
    public class WTMDbContextCreator<TShardingDbContext> : IDbContextCreator<TShardingDbContext> where TShardingDbContext : DbContext, IShardingDbContext
    {
        public DbContext CreateDbContext(DbContext shellDbContext, ShardingDbContextOptions shardingDbContextOptions)
        {
            var context = new DataContext((DbContextOptions<FrameworkContext>)shardingDbContextOptions.DbContextOptions);
            context.RouteTail = shardingDbContextOptions.RouteTail;
            return context;
        }
    }
}
